#!/bin/bash
echo $1
gdir="gaus"
if [ "$1" = "fnl99" -o "$1" = "fnl500" ]; then
  gdir="gaus2"
fi
echo $gdir
cd $1/bias
for np in 50 100
do
  for z in 0 1 2
  do
    for seed in 0 1 2 3 # again this assumes that the seed naming is consistent; this could be checked by doing all the computations once again by rerunning the scripts.
    do
      awk 'NR==FNR{a[NR]=$2; next} {print $1, a[FNR]/$2}' power.z${z}.${np}.stoch.${seed} ../../${gdir}/bias/power.z${z}.${np}.stoch.${seed} > power.z${z}.${np}.ngstoch.${seed}
    done
    # take the average after 4 seeds are done
    ~/Research/feedersim/Tools/avg power.z${z}.${np}.ngstoch 4
  done
done

# work on z=0, np =200 separately
for seed in 0 1 2 3
do
  awk 'NR==FNR{a[NR]=$2; next} {print $1, a[FNR]/$2}' power.z0.200.stoch.${seed} ../../${gdir}/bias/power.z0.200.stoch.${seed} > power.z0.200.ngstoch.${seed}
done
~/Research/feedersim/Tools/avg power.z0.200.ngstoch 4
